#pragma once

#include <chrono>
#include <cstdint>

namespace cpp_sdk_test {
class Timer {
public:
    Timer() = default;
    ~Timer() = default;

    void Start() { start_ = std::chrono::high_resolution_clock::now(); }
    void End() { end_ = std::chrono::high_resolution_clock::now(); }

    uint64_t AverageTime(uint64_t times = 1) {
        times = times == 0 ? 1 : times;
        return std::chrono::duration_cast<std::chrono::microseconds>(end_ -
                                                                     start_)
                   .count() /
               times;
    }

private:
    std::chrono::high_resolution_clock::time_point start_;
    std::chrono::high_resolution_clock::time_point end_;
};
}  // namespace cpp_sdk_test
